import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map.Entry;

import org.junit.Test;


public class MyTest{
    @Test
    public void test1(){
        System.out.println(cacu("dan")==cacu("and"));
    }

    public List<List<String>> groupAnagrams(String[] strs) {
        Hashtable<Double,ArrayList<String>> result=new Hashtable<Double,ArrayList<String>>();
        ArrayList<List<String>> ans=new ArrayList<List<String>>();

        for(String s:strs){
            ArrayList<String> arrayList= result.getOrDefault(cacu(s),new ArrayList<String>());
            arrayList.add(s);
            result.put(cacu(s), arrayList);
        }

        for(Entry<Double,ArrayList<String>> entry:result.entrySet()){
            ans.add(entry.getValue());
        }
        return ans;
    }
    private double cacu(String s){
        double ans=0;
        for(char c:s.toCharArray()){
            ans+=Math.log(Math.log(c));
        }
        return Math.round(ans*1000000000);
    }
}